//
//  ViewControllerOne.m
//  Quartz
//
//  Created by thinkjoy on 2017/6/29.
//  Copyright © 2017年 杜瑞胜. All rights reserved.
//

#import "ViewControllerOne.h"
#import "ViewOne.h"
#import "ViewTwo.h"
#import "NSDate+RSTool.h"

@interface ViewControllerOne ()
@property   (weak,nonatomic)    IBOutlet    UISlider * slider;
- (IBAction)sliderHadChanged:(UISlider *)sender;

@property   (nonatomic,strong)  ViewOne * viewOne;
@property   (nonatomic,strong)  ViewTwo * viewTwo;

/** timer*/
@property (nonatomic, strong) NSTimer *timer;
@end

@implementation ViewControllerOne

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor   =   [UIColor blackColor];
    
    ViewOne * viewOne   =   [[ViewOne alloc] initWithFrame:CGRectMake(20, 80, 220, 220)];
    viewOne.backgroundColor =   [UIColor blackColor];
    [self.view addSubview:viewOne];
    _viewOne    =   viewOne;
    
    ViewTwo * viewTwo   =   [[ViewTwo alloc] initWithFrame:CGRectMake(20, 80, 220, 220)];
    viewTwo.backgroundColor =   [UIColor clearColor];
    [self.view addSubview:viewTwo];
    _viewTwo    =   viewTwo;
    
    self.timer = [NSTimer scheduledTimerWithTimeInterval:.1f repeats:YES block:^(NSTimer * _Nonnull timer) {
        [self.viewTwo setNeedsDisplay];
    }];
    [self.timer fire];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)sliderHadChanged:(UISlider *)sender {
    [_viewOne setFrame:CGRectMake(20, 80, 220*sender.value*2, 220*sender.value*2)];
    [_viewTwo setFrame:CGRectMake(20, 80, 220*sender.value*2, 220*sender.value*2)];
}
@end
